<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">
    <ui:define name="content">   

            <h1>Product Edit Price Control</h1>
            <h:form id="form">
                <p:panel header="Create a new book" id="panel">
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>

                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />

                    <h:panelGrid columns="2" id="grid">
                        <h:outputLabel value="Price : *" for="txt_title"></h:outputLabel>
                        <p:inputText id="txt_title" 
                                     value="#{productManagerBean.priceControl.price}" required="true"/>

                        <h:outputLabel value="Type:"/>
                        <h:selectOneMenu id="city" value="#{productManagerBean.priceControl.type}">  
                            <f:selectItems value="#{productManagerBean.dayOfWeek}" />  
                            <p:ajax update="calendar" />  
                        </h:selectOneMenu>  

                        <h:outputLabel value="Specific Date :"/>
                        <p:calendar id="calendar" value="#{productManagerBean.priceControl.specificDate}" disabled="#{productManagerBean.priceControl.type!=8}"/>


                        <h:outputLabel value="Start Hour: *" for="startHour"/>
                        <h:selectOneMenu id="startHour" value="#{productManagerBean.priceControl.startTime}">  
                            <f:selectItems value="#{productManagerBean.timeOfDay}" />  
                        </h:selectOneMenu>  

                        <h:outputLabel value="End Hour: *" for="endHour"/>
                        <h:selectOneMenu id="endHour" value="#{productManagerBean.priceControl.endTime}">  
                            <f:selectItems value="#{productManagerBean.timeOfDay}" />  
                        </h:selectOneMenu>  

                        <p:commandButton id="reset" value="Reset" type="reset"/>
                        <p:commandButton id="add" value="Add" update="form"
                                         actionListener="#{productManagerBean.addPriceControl}" ajax="true" />
                    </h:panelGrid>
                </p:panel>

                <p:outputPanel id="books">
                    <p:dataTable value="#{productManagerBean.listOfPriceControl}" var="list" 
                                 rowEditListener="#{productManagerBean.editPriceControl}" onRowEditUpdate ="panel">

                        <p:column headerText="Price" style="width:150px">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{list.price}" />  
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:inputText value="#{list.price}" style="width:100%"/>  
                                </f:facet>  
                            </p:cellEditor>
                        </p:column>

                        <p:column headerText="Type" style="width:150px">
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:selectOneMenu value="#{list.type}" disabled="true">  
                                        <f:selectItems value="#{productManagerBean.dayOfWeek}" />                                    
                                    </h:selectOneMenu>   
                                </f:facet>  
                                <f:facet name="input">  
                                    <h:selectOneMenu value="#{list.type}" >  
                                        <f:selectItems value="#{productManagerBean.dayOfWeek}" />   
                                        <p:ajax update="calendar1" />  
                                    </h:selectOneMenu>  
                                </f:facet>  
                            </p:cellEditor>
                        </p:column>     

                        <p:column headerText="Specific Date" style="width:150px">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <p:calendar value="#{list.specificDate}" disabled="true"/>
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:calendar id="calendar1" value="#{list.specificDate}" disabled="#{list.type!=8}"/>
                                </f:facet>  
                            </p:cellEditor>
                        </p:column>

                        <p:column headerText="Start Time" style="width:150px">
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:selectOneMenu value="#{list.startTime}" disabled="true">  
                                        <f:selectItems value="#{productManagerBean.timeOfDay}" />                                    
                                    </h:selectOneMenu>   
                                </f:facet>  
                                <f:facet name="input">  
                                    <h:selectOneMenu value="#{list.startTime}" >  
                                        <f:selectItems value="#{productManagerBean.timeOfDay}" />   
                                    </h:selectOneMenu>  
                                </f:facet>  
                            </p:cellEditor>
                        </p:column>  

                        <p:column headerText="End Time" style="width:150px">
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:selectOneMenu value="#{list.endTime}" disabled="true">  
                                        <f:selectItems value="#{productManagerBean.timeOfDay}" />                                    
                                    </h:selectOneMenu>   
                                </f:facet>  
                                <f:facet name="input">  
                                    <h:selectOneMenu value="#{list.endTime}" >  
                                        <f:selectItems value="#{productManagerBean.timeOfDay}" />   
                                    </h:selectOneMenu>  
                                </f:facet>  
                            </p:cellEditor>
                        </p:column>  

                        <p:column headerText="Options">  
                            <p:rowEditor/>  
                        </p:column>  
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Operation" />
                            </f:facet>
                            <p:commandButton value="Remove" update="form" actionListener="#{productManagerBean.removePriceControl(list.id)}" ajax="true">
                            </p:commandButton>
                        </p:column>

                    </p:dataTable>
                </p:outputPanel>
            </h:form>	
    </ui:define>
</ui:composition>